package View.SetupScreens;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

import Model.Game;
import Model.Player;

/**
 * Creates the JComponents for ColorChooser
 * @author jweinflash
 *
 */
public class ColorChooser extends JPanel {
	public final Game game;
	public JLabel headerLabel;
	public JLabel p1Label;
	public JLabel p2Label;
	public JLabel p3Label;
	public JLabel p4Label;
	public JLabel warningLabel;
	public JLabel confirmLabel;
	
	public JComboBox p1comboBox;
	public JComboBox p2comboBox;
	public JComboBox p3comboBox;
	public JComboBox p4comboBox;
	public JButton setColorsButton;
	
	/** 
	 * @author: Josh Weinflash
	 * @Description: Implements the screen that allows players to choose their colors
	 */
	public ColorChooser(final Game game) {
		this.game = game;
		setBackground(Color.BLACK);
		setLayout(null);
		setPreferredSize(new Dimension(1200, 800));
		 
		initializeColorChooser();
		addComponents();
		
	}
	
	/**
	 * @Description: Initializes the ColorChooser Panel with its attributes
	 */
	private void initializeColorChooser()
	{
		
		/* initialize 'CHOOSE YOUR COLOR' label */
		headerLabel = new JLabel("CHOOSE YOUR COLOR");
		headerLabel.setFont(new Font("Helvetica", Font.PLAIN, 70));
		headerLabel.setForeground(new Color(204, 153, 0));	
		headerLabel.setBounds(187, 25, 825, 141);
		
		/* initialize 'PLAYER X' labels */
		p1Label = new JLabel("PLAYER 1");
		p1Label.setHorizontalAlignment(SwingConstants.CENTER);
		p1Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p1Label.setForeground(new Color(204, 153, 0));	
		p1Label.setBounds(353, 191, 182, 40);
		
		p2Label = new JLabel("PLAYER 2");
		p2Label.setHorizontalAlignment(SwingConstants.CENTER);
		p2Label.setForeground(new Color(204, 153, 0));
		p2Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p2Label.setBounds(353, 261, 182, 47);
		
		p3Label = new JLabel("PLAYER 3");
		p3Label.setHorizontalAlignment(SwingConstants.CENTER);
		p3Label.setForeground(new Color(204, 153, 0));
		p3Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p3Label.setBounds(353, 338, 182, 47);
		
		p4Label = new JLabel("PLAYER 4");
		p4Label.setHorizontalAlignment(SwingConstants.CENTER);
		p4Label.setForeground(new Color(204, 153, 0));
		p4Label.setFont(new Font("Helvetica", Font.PLAIN, 30));
		p4Label.setBounds(353, 415, 182, 47);
		
		/* initialize warning and confirmation labels */
		warningLabel = new JLabel("INVALID SELECTION - PLAYER COLORS MUST BE UNIQUE. PLEASE RESELECT");
		warningLabel.setHorizontalAlignment(SwingConstants.CENTER);
		warningLabel.setForeground(Color.RED);
		warningLabel.setFont( new Font("Helvetica", Font.PLAIN, 20));
		warningLabel.setBounds(180, 552, 840, 47);
		warningLabel.setVisible(false);
		
		confirmLabel = new JLabel("PLAYER COLORS SET. CLICK NEXT TO CONTINUE");
		confirmLabel.setHorizontalAlignment(SwingConstants.CENTER);
		confirmLabel.setForeground(Color.GREEN);
		confirmLabel.setFont( new Font("Helvetica", Font.PLAIN, 20));
		confirmLabel.setBounds(282, 552, 635, 47);
		confirmLabel.setVisible(false);	
		
		/* initialize ComboBoxes */
		String [] playerColors = { "RED", "BLUE", "GREEN", "YELLOW" };

		p1comboBox = new JComboBox(playerColors);
		p1comboBox.setBounds(639, 197, 138, 27);
		
		
		p2comboBox = new JComboBox(playerColors);
		p2comboBox.setBounds(639, 267, 138, 27);
		p2comboBox.setSelectedIndex(1);

		p3comboBox = new JComboBox(playerColors);
		p3comboBox.setBounds(639, 344, 138, 27);
		p3comboBox.setSelectedIndex(2);
	
		p4comboBox = new JComboBox(playerColors);
		p4comboBox.setBounds(639, 421, 138, 27);
		p4comboBox.setSelectedIndex(3);
		
		/* initialize JButton */
		setColorsButton = new JButton("SET PLAYER COLORS");
		setColorsButton.setBounds(313, 588, 573, 79);
		setColorsButton.setBackground(Color.BLACK);
		setColorsButton.setForeground(new Color(204, 153, 0));
		setColorsButton.setFont(new Font("Helvetica", Font.PLAIN, 45));
		setColorsButton.setBorderPainted(false);
		

					
	}
	/**
	 * helper method to add components to the Jpanel
	 */
	private void addComponents()
	{
		add(headerLabel);
		add(p1Label);
		add(p2Label);
		add(p3Label);
		add(p4Label);
		add(warningLabel);
		add(confirmLabel);
		
		add(p1comboBox);		
		add(p2comboBox);
		add(p3comboBox);
		add(p4comboBox);		
	
		add(setColorsButton);
						
	}
}

